﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetClientInfoByCooperatorID]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetClientInfoByCooperatorID];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetClientInfoByCooperatorID]
@cooperatorID int
/*--------------------------------------
功能：根据协同人id得到他所协同的所有客户信息
参数：
    @cooperatorID    协同人ID
--------------------------------------*/
AS
    SELECT c.*,convert(nvarchar(10),c.UpdateTime,120) as updatetime1,UDS_CM_Linkman.Name AS Linkman
    FROM UDS_CM_ClientContact_Cooperatingman a,UDS_CM_ClientContact b,UDS_CM_ClientInfo c LEFT JOIN UDS_CM_Linkman 
    ON UDS_CM_Linkman.ID=c.ChiefLinkmanID
    WHERE a.ContactID=b.id AND b.ClientID=c.id AND a.CooperatingmanID=@cooperatorID
    ORDER BY c.UpdateTime DESC